import numpy as np

# 列表
data_list = [1, 2, 3]
print(data_list)
# 1.创建一维数组
arr1 = np.array([10, 20, 30])
print(arr1)
print("shape:", arr1.shape)
print("size:", arr1.size)
print("ndim:", arr1.ndim)

arr2 = np.arange(5)
print(arr2)

# 2.创建二维数组
arr3 = np.array([[1, 2, 3], [4, 5, 6]])
print(arr3)
print("------------------------")
# 3.数组的运算
arr4 = np.array([20, 40, 60])
arr5 = np.array([2, 4, 6])
result1 = arr4 - arr5
print(result1)

# 4.矩阵元素全部是0
arr6 = np.zeros((2, 3))
print(arr6)

# 5.矩阵元素全部是1
arr7 = np.ones((3, 3), dtype=np.int32)
print(arr7)

# 6.创建主对角线为1，其余元素为0的方阵
arr8 = np.identity(4, dtype=np.int32)
print(arr8)
print("----------")
# 7.创建主对角线为1，其余元素为0的矩阵
arr9 = np.eye(3, 4)
print(arr9)
